<?php

use think\migration\Migrator;
use think\migration\db\Column;

class City extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->execute(
            "DROP TABLE IF EXISTS `sys_city`;
            CREATE TABLE IF NOT EXISTS `sys_city` (
              `id` int(11) not null primary key auto_increment comment '主键',
              `name` nvarchar(128) not null default '' comment '名称',
              `full_name` nvarchar(256) not null default ''comment '全称',
              `pid` int(11) not null default 0 comment '父级ID',
              `create_time` datetime not null default now() comment '创建时间',
              `update_time` datetime not null default now() comment '更新时间',
              `has_child` enum('false','true') not null default 'false' comment '是否有子节点'
            ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COMMENT='城市表';"
        );
    }
}
